import http from '../index'

// 分页获取网点
export const getOutlets = ({ ascended = null, current = null, size = null, sortFieldName = null, status = null, wardAddress = null, fullAddress = null, outletsMember = null, outletsName = null, outletsPhone = null, parentTreeCode = null, serviceRangeType = null }) => {
    return http.get("outlets", { ascended, current, size, sortFieldName, status, wardAddress, fullAddress, outletsMember, outletsName, outletsPhone, parentTreeCode, serviceRangeType })
}

// 获取网点树
export const getOutletsAll = () => {
    return http.get("outlets/all")
}

// 根据sid获取网点
export const getOutletDetail = ({ sid }) => {
    return http.get("outlets/" + sid)
}

// 根据网点SID查询网点服务的行政区划编码
export const getOutletDistrictCodes = ({ sid }) => {
    return http.get("outlets/" + sid + "/district-codes")
}

// 根据网点SID查询网点服务的电子围栏坐标
export const getOutletElectronics = ({ sid }) => {
    return http.get("outlets/" + sid + "/electronics")
}

// 根据网点sid查询绑定的员工
export const getOutletUsers = ({ sid }) => {
    return http.get("outlets/" + sid + "/users")
}

// 新增网点
export const addOutlet = ({ districtCode, fullAddress, latitude, logoUrl, longitude, outletsMember, outletsName, outletsPhone, serviceRangeType, wardAddress, electronicfenceLatitudeLongitude = null, regionDistrictCode = null, userSid = null, viewSort = null, note = null, status = null, parentTreeCode = null }) => {
    return http.post("outlets", { districtCode, fullAddress, latitude, logoUrl, longitude, outletsMember, outletsName, outletsPhone, serviceRangeType, wardAddress, electronicfenceLatitudeLongitude, regionDistrictCode, viewSort, note, status })
}

// 修改网点
export const editOutlet = ({ sid, districtCode, fullAddress, latitude, logoUrl, longitude, outletsMember, outletsName, outletsPhone, serviceRangeType, wardAddress, electronicfenceLatitudeLongitude = null, regionDistrictCode = null, userSid = null, viewSort = null, note = null, status = null }) => {
    return http.put("outlets/" + sid, { districtCode, fullAddress, latitude, logoUrl, longitude, outletsMember, outletsName, outletsPhone, serviceRangeType, wardAddress, electronicfenceLatitudeLongitude, regionDistrictCode, viewSort, note, status })
}

// 批量删除网点
export const delOutlets = ({ sidList }) => {
    return http.put("outlets/delete", { sidList })
}

// 根据sid启用-停用网点
export const changeOutletStatus = ({ sid }) => {
    return http.put("outlets/" + sid + "/status")
}
